package main

import "fmt"

// 继承
type Animal struct {
	name string
	age  int
}

func (animal Animal) eat() {
	fmt.Println(animal.name, "正在eat")
}
func (animal Animal) sleep() {
	fmt.Println(animal.name, "正在sleep")
}

type Dog02 struct {
	Animal
}

type Cat02 struct {
	Animal
	Color string
}

func (cat Cat02) eat() {
	fmt.Println(cat.name, "正在eat--cat")
}

func (cat Cat02) miao() {
	fmt.Println(cat.name, "正在miao--cat")
}

func main() {
	dog := Dog02{Animal{name: "name1", age: 1}}
	dog.eat()

	cat := Cat02{Animal{name: "cat01", age: 2}, "red"}
	cat.miao()
	cat.eat()
}
